package com.stationbuilding.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.stationbuilding.R;
import com.stationbuilding.adapter.FragmentPagerAdapter;
import com.stationbuilding.fragment.safe.DetailsFragment;
import com.stationbuilding.fragment.safe.FlowFragment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class HandleActivity extends AppCompatActivity {

    private ImageView agreeImg;
    private TextView agree;
    private ImageView disagreeImg;
    private TextView disagree;
    private ImageView voiceImg;
    private TextView voice;
    private ImageView photoImg;
    private TextView photo;
    private ImageView takePhotoImg;
    private TextView takePhoto;
    private ImageView videoImg;
    private TextView video;
    // 点击事件监听监听
    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.back:
                    finish();
                    break;
                case R.id.button:
                    finish();
                    break;
                case R.id.agree_img:
                case R.id.agree:
                    changeStatus(true);
                    break;
                case R.id.disagree_img:
                case R.id.disagree:
                    changeStatus(false);
                    break;
                case R.id.voice_img:
                case R.id.voice:
                    changeStatus(false);
                    break;
                case R.id.photo_img:
                case R.id.photo:
                    changeStatus(false);
                    break;
                case R.id.take_photo_img:
                case R.id.take_photo:
                    changeStatus(false);
                    break;
                case R.id.video_img:
                case R.id.video:
                    changeStatus(false);
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_handle);
        // 初始化toolbar
        initToolbar();
        // 初始化View
        initView();
    }

    private void initToolbar() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        ImageView back = (ImageView) toolbar.findViewById(R.id.back);
        Button button = (Button) toolbar.findViewById(R.id.button);
        TextView title = (TextView) toolbar.findViewById(R.id.title);
        title.setText(getResources().getText(R.string.safe_question));
        button.setText(getResources().getString(R.string.send));
        button.setVisibility(View.VISIBLE);
        button.setOnClickListener(onClickListener);
        back.setOnClickListener(onClickListener);
    }

    private void initView() {
        agreeImg = (ImageView) findViewById(R.id.agree_img);
        agree = (TextView) findViewById(R.id.agree);
        disagreeImg = (ImageView) findViewById(R.id.disagree_img);
        disagree = (TextView) findViewById(R.id.disagree);
        voiceImg = (ImageView) findViewById(R.id.voice_img);
        voice = (TextView) findViewById(R.id.voice);
        photoImg = (ImageView) findViewById(R.id.photo_img);
        photo = (TextView) findViewById(R.id.photo);
        takePhotoImg = (ImageView) findViewById(R.id.take_photo_img);
        takePhoto = (TextView) findViewById(R.id.take_photo);
        videoImg = (ImageView) findViewById(R.id.video_img);
        video = (TextView) findViewById(R.id.video);
        agreeImg.setOnClickListener(onClickListener);
        agree.setOnClickListener(onClickListener);
        disagreeImg.setOnClickListener(onClickListener);
        disagree.setOnClickListener(onClickListener);
        voiceImg.setOnClickListener(onClickListener);
        voice.setOnClickListener(onClickListener);
        photoImg.setOnClickListener(onClickListener);
        photo.setOnClickListener(onClickListener);
        takePhotoImg.setOnClickListener(onClickListener);
        takePhoto.setOnClickListener(onClickListener);
        videoImg.setOnClickListener(onClickListener);
        video.setOnClickListener(onClickListener);
    }

    private void changeStatus(boolean agreeFlg) {
        if (agreeFlg) {
            agreeImg.setImageResource(R.mipmap.agree_selected);
            agree.setTextColor(ContextCompat.getColor(this, R.color.black));
            disagreeImg.setImageResource(R.mipmap.disagree);
            disagree.setTextColor(ContextCompat.getColor(this, R.color.gray_8f));
        } else {
            agreeImg.setImageResource(R.mipmap.agree);
            agree.setTextColor(ContextCompat.getColor(this, R.color.gray_8f));
            disagreeImg.setImageResource(R.mipmap.disagree_selectd);
            disagree.setTextColor(ContextCompat.getColor(this, R.color.black));
        }
    }
}
